@extends('admin.app')

@section('breadcrumb')
    <div class="bg-light lter b-b wrapper-md">
        <ol class="breadcrumb bg-light lter m-n no-padder">
            <li><a href="{{ admin_action('HomeController@index') }}">主页</a></li>
            <li>业务管理</li>
            <li class="active">还款管理</li>
        </ol>
    </div>
@endsection

@section('content')
<div class="panel panel-default">
  <div class="panel-heading font-bold">还款记录</div>
  <div class="panel-body">
    <form class="form-horizontal" method="get" action="{{ admin_action('Business\RepaymentManagementController@index') }}">

      <div class="form-group">
                        <div class="col-sm-5">
                            <div class="form-group">
                                <label class="control-label col-sm-4">还款人:</label>
                                <div class="col-sm-8">
            <input type="text" class="form-control" name="name" value="{{ $query['name'] ?? '' }}" placeholder="请输入还款人">
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-5">
                            <div class="form-group">
                                <label class="control-label col-sm-4">项目名称:</label>
                                <div class="col-sm-8">
          <input type="text" class="form-control" name="project_name" value="{{ $query['project_name'] ?? '' }}" placeholder="请输入项目名称">
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-5">
                            <div class="form-group">
                                <label class="control-label col-sm-4">保函号:</label>
                                <div class="col-sm-8">
          <input type="text" class="form-control" name="collateral_licence_no" value="{{ $query['collateral_licence_no'] ?? '' }}" placeholder="请输入查询的保函号">
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-5">
                            <div class="form-group">
                                <label class="control-label col-sm-4">还款状态:</label>
                                <div class="col-sm-8">
          <select name="status" class="form-control">
              <option value="">全部</option>
              <option value="1" {{$query['status']==1?'selected="selected"':''}}>已还款</option>
              <option value="0" {{$query['status']=='0'?'selected="selected"':''}}>待还款</option>
          </select>
                                </div>
                            </div>
                        </div>
        <div class="pull-right m-r">
          <button class="btn btn-primary" type="submit">查询</button>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-1 control-label">应还款时间</label>
        <div class="col-sm-5">
          <input type="text" class="form-control datetimepicker" name="start_at" value="{{ $query['start_at'] }}" placeholder="默认当前起始时间">
        </div>
        <div class="col-sm-5">
          <input type="text" class="form-control datetimepicker" name="end_at" value="{{$query['end_at']}}" placeholder="默认当天结束时间">
        </div>
      </div>
    </form>
    <div class="table-responsive">
        <table class="table table-striped b-t b-light">
          <thead>
            <tr>
              <th>还款笔数</th>
              <th>总额合计</th>
              <th>本金合计</th>
              <th>利息合计</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>{{ $tj['bs'] }}</td>
              <td>{{ $tj['money_sum'] + $tj['profit_sum'] }}</td>
              <td>{{ $tj['money_sum'] }}</td>
              <td>{{ $tj['profit_sum'] }}</td>
            </tr>
          </tbody>
        </table>
        <table class="table table-striped b-t b-light">
            <thead>
            <tr>
                <th>项目编号</th>
                <th>项目名称</th>
                <th>保函号</th>
                <th>还款人</th>
                <th>还款总金额(元)</th>
                <th>应还款时间</th>
                <th>还款时间</th>
                <th>应还本金(元)</th>
                <th>应还利息(元)</th>
                <th>还款状态</th>
                <th></th>
            </tr>
            </thead>
            <tbody>
            @forelse ($data as $d)
                <tr>
                    <td>{{ $d->id??'--' }}</td>
                    <td>{{ $d->projects_name??'--' }}</td>
                    <td>{{ $d->collateral_licence_no??'--' }}</td>
                    <td>{{ $d->name??'--' }}</td>
                    <td>{{ ($d->money + $d->profit)??0 }}</td>
                    <td>{{ $d->input_time??'--' }}</td>
                    <td>{{ $d->pay_time??'--' }}</td>
                    <td>{{ $d->money??0 }}</td>
                    <td>{{ $d->profit??0 }}</td>
                    <td>
                    @if($d->status == 1)
                  		已还款
                		@elseif($d->status == 0)
                			待还款
                		@else
                			还款失败
                		@endif
                    </td>
                    <td>
                      <a class="btn btn-xs btn-info" href="{{ admin_action('Business\RepaymentManagementController@repaymentInfo',[($d->input_time??$d->pay_time),$d->id]) }}"">详细</a>
                    </td>
                </tr>
            @empty
                <tr>
                    <td colspan="9" class="text-center">没有找到还款记录</td>
                </tr>
            @endforelse
            </tbody>
        </table>
    </div>
  </div>
  <div class="panel-footer">
      <div class="row">
          <div class="col-sm-12 text-right text-center-xs">
              {!! $links !!}
          </div>
      </div>
  </div>
</div>
@endsection